home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / dskutl / hdsource.arc / HDECC.ASM < prev    next >
Assembly Source File  |  1986-02-24  |  12KB  |  340 lines

  1.      PAGE     64,132            ;PAGE WIDTH,LENGTH
  2.      .SALL
  3.      TITLE     PC/AT DIAGNOSTIC - ECC TEST
  4. ; **********************************************************************
  5. ; *                                       *
  6. ; *    MODULE NAME    HDECC                           *
  7. ; *    AUTHOR           JIM BRACKING                       *
  8. ; *                                       *
  9. ; *    DECSRIPTION    THIS PROGRAM PERFORMS THE FOLLOWING           *
  10. ; *               FUNCTIONS:                       *
  11. ; *                                       *
  12. ; *               1.  WRITE ALL SECTORS ON THE DIAG CYLINDER      *
  13. ; *               WITH THE WORST CASE DATA PATTERN USING      *
  14. ; *               THE WRITE LONG CMD. WHEN THEY ARE READ      *
  15. ; *               BACK THE STATUS SHOULD BE A CORRECTABLE     *
  16. ; *               DATA ERROR.                       *
  17. ; **********************************************************************
  18. ;
  19. ; **********************************************************************
  20. ; *            EXTERNAL PROGRAM REFERENCES               *
  21. ; **********************************************************************
  22.      EXTRN     SCRMGR:NEAR
  23. ; **********************************************************************
  24. ; *              EXTERNAL DATA REFERENCES               *
  25. ; **********************************************************************
  26.      INCLUDE HDDATA.ASM
  27. ; **********************************************************************
  28. ; *            EXTERNAL SUBROUTINE REFERENCES               *
  29. ; **********************************************************************
  30.      INCLUDE HDSUB.ASM
  31. ; **********************************************************************
  32. ; *                PUBLIC DECLARES                   *
  33. ; **********************************************************************
  34.      PUBLIC  HDECC
  35. ; **********************************************************************
  36. ; *                 MACROS                    *
  37. ; **********************************************************************
  38.      IF1
  39.      INCLUDE HD.MAC
  40.      INCLUDE \SCRMGR\SCRNWORK.MAC
  41.      ENDIF
  42. ; **********************************************************************
  43. ; *                                       *
  44. ; *                   BEGIN                       *
  45. ; *                                       *
  46. ; **********************************************************************
  47. CSEG     SEGMENT PARA PUBLIC 'CODE'
  48.      ASSUME CS:CSEG
  49. HDECC  PROC    NEAR
  50.      ASSUME  DS:CSEG           ;DATA SEGMENT
  51.      JMP     BY_ID               ;JMP AROUND ID
  52.      ID     HDECC
  53.      INCLUDE \SCRMGR\SCRNWORK.ASM
  54. ; **********************************************************************
  55. ; *             EQUATES AND STRUCTURES                *
  56. ; **********************************************************************
  57.      INCLUDE HDEQU.ASM
  58. ; **********************************************************************
  59. ; *                 SCREENS                   *
  60. ; **********************************************************************
  61. ;
  62. ;
  63.   SFIELD X00,X01,,@LABEL,RV,23,02,'CTRL-F1 TO START'
  64.   SFIELD X01,X02,,@LABEL,RV,23,29,'ESC FOR THE MAIN MENU'
  65.   SFIELD X02,X00,,@LABEL,RV,23,62,'CTRL-BRK TO STOP'
  66. ;
  67.   SFIELD XI0,XI1,,@LABEL,LO,19,05,'DRIVE =>'
  68.   SFIELD XI1,XI2,1,@EX+@NUM+@UC+@NFULL+@REQ,LO,19,14
  69.   SFIELD XI2,XI3,,@LABEL,LO,20,05,'(1 OR 2)'
  70.   SFIELD XI3,XI4,,@LABEL,LO,19,20,'RUN CONTINIOUSLY =>'
  71.   SFIELD XI4,XI5,1,@UC+@EX+@YN+@NFULL+@REQ,LO,19,40
  72.   SFIELD XI5,XI0,,@LABEL,LO,20,26,'(Y OR N)'
  73. ;
  74.   SFIELD XS0,XS1,,@LABEL,LO,19,46,'STATUS =>'
  75.   SFIELD XS1,XS0,,@LABEL,LO,19,56,'** IDLE **   '
  76. ;
  77.   SFIELD XS2,XS3,,@LABEL,LO,19,46,'STATUS =>'
  78.   SFIELD XS3,XS2,,@LABEL,HI,19,56,'** WORKING **'
  79. ;
  80.   SFIELD XC0,XC1,,@LABEL,LO,20,46,'CYLINDER =>'
  81.   SFIELD XC1,XC0,04,@LABEL,LO,20,58
  82. ;
  83.   SFIELD XE0,XE1,,@LABEL,LO,21,46,'ERRORS =>'
  84.   SFIELD XE1,XE0,05,@LABEL,LO,21,56
  85. ;
  86.   SFIELD T05,T05,,@LABEL,RV,17,35,'ECC TEST'
  87. BY_ID:
  88. HDECC  ENDP
  89. ; *********************************************************************
  90. ; *                                      *
  91. ; *                   ECC TEST                   *
  92. ; *                                      *
  93. ; *********************************************************************
  94. ECC     PROC
  95.      CLS     LO,4,1,23,78           ;CLEAR THE SCREEN
  96.      BOX     17,0,08,80,LO           ;OUTLINE
  97.      WRITEC  0CCH,LO,17,0,1        ;  THE
  98.      WRITEC  0B9H,LO,17,79,1       ;  SCREEN
  99.      WRITE     T05               ;TYPE OF TEST
  100.      WRITE     X00               ;COMMANDS
  101. ECC_00:
  102.      WRITE     XS0               ;STATUS
  103.      LEA     BX,XI1            ;DRIVE ENTRY
  104.      MOV     [BX].S_ATTR,LO        ;RESTORE ATTRIBUTE
  105.      CMP     ALL_SW,0FFH           ;RUN ALL TEST??
  106.      JE     ECC_01            ;YES
  107.      MOV     [BX].S_DATA,' '       ;CLEAR DRIVE
  108.      JMP     ECC_01A           ;CONTINUE
  109. ECC_01:
  110.      LEA     BX,XI4            ;Y/N ENTRY
  111.      MOV     [BX].S_ATTR,LO        ;RESTORE ATTRIBUTE
  112.      MOV     [BX].S_DATA,'Y'       ;DEFAULT NO
  113.      MOV     AL,DR               ;FETCH DRIVE
  114.      INC     AL               ;NUMBER
  115.      OR     AL,30H            ;MAKE IT A NUMBER
  116.      MOV     [BX].S_DATA,AL        ;SET IT IN THE MSG
  117.      WRITE     XI0               ;DRIVE
  118.      JMP     ECC_15            ;CONTINUE
  119. ECC_01A:
  120.      LEA     BX,XI4            ;Y/N ENTRY
  121.      MOV     [BX].S_ATTR,LO        ;RESTORE ATTRIBUTE
  122.      MOV     [BX].S_DATA,'N'       ;DEFAULT NO
  123.      WRITE     XI0               ;DRIVE
  124. ECC_02:
  125.      READR     BX               ;FETCH DRIVE
  126.      CALL     TRANS_KEY           ;TRANSLATE THE KEY
  127.      JNC     ECC_04            ;SUCESSFULL
  128. ECC_03:
  129.      CALL     BEEP               ;RING THE BELL
  130.      JMP     ECC_02            ;TRY AGAIN
  131. ECC_04:
  132.      CMP     AL,ESC_KEY           ;ESCAPE KEY??
  133.      JNE     ECC_05            ;NO
  134.      JMP     EXIT               ;RETURN
  135. ECC_05:
  136.      CMP     AL,C_BRK           ;CONTROL BREAK KEY??
  137.      JNE     ECC_07            ;NO
  138.      JMP     ECC               ;YES - START OVER
  139. ECC_07:
  140.      CMP     AL,C_F1           ;CTRL_F1??
  141.      JNE     ECC_03            ;NO - INVALID KEY
  142.      LEA     BX,XI1            ;DRIVE ENTRY
  143.      MOV     [BX].S_ATTR,LO        ;RESTORE ATTRIBUTE
  144.      MOV     AL,[BX].S_DATA        ;FETCH DRIVE NUMBER
  145.      CMP     AL,'1'                ;VALID DRIVE??
  146.      JE     ECC_08            ;YES
  147.      CMP     AL,'2'                ;VALID DRIVE??
  148.      JE     ECC_08            ;YES
  149.      MOV     [BX].S_ATTR,HI        ;HIGHLIGHT IT
  150.      PMSG     22               ;DISPLAY THE MESSAGE
  151.      CALL     BEEP               ;RING THE BELL
  152.      WRITE     XI0               ;DRIVE + INTERLEAVE
  153.      JMP     ECC_02            ;TRY AGAIN
  154. ECC_08:
  155.      AND     AL,0FH            ;ADJUST
  156.      DEC     AL               ;  DRIVE NUMBER
  157.      CMP     AL,NUM_DR           ;DRIVE INSTALLED
  158.      JB     ECC_10            ;YES
  159.      MOV     [BX].S_ATTR,HI        ;HIGHLIGHT IT
  160.      PMSG     21               ;DISPLAY THE MESSAGE
  161.      CALL     BEEP               ;RING THE BELL
  162.      WRITE     XI0               ;DRIVE + INTERLEAVE
  163.      JMP     ECC_02            ;TRY AGAIN
  164. ECC_10:
  165.      MOV     DR,AL               ;SAVE DRIVE NUMBER
  166.      LEA     BX,XI1            ;DRIVE ENTRY
  167.      MOV     [BX].S_ATTR,LO        ;RESTORE ATTRIBUTE
  168.      WRITE     XI0               ;DRIVE
  169. ECC_15:
  170.      XOR     AX,AX               ;DATA PATTERN
  171.      MOV     CX,256            ;NUMBER OF WORDS
  172.      CLD                   ;FORWARD DIRECTION
  173.      LEA     DI,DATA_BUF           ;OUTPUT
  174.      PUSH     CS               ;ESTABLISH
  175.      POP     ES               ;  SEGMENT
  176.      REP     STOSW               ;FILE THE BUFFER
  177. ECC_20:
  178.      CALL     READ_PARMS           ;FETCH DRIVE PARMS
  179.      MOV     CUR_HD,0           ;INITIALIZE
  180.      MOV     CUR_SEC,1           ; THE
  181.      MOV     CUR_CYL,0           ;  STARTING FIELDS
  182.      MOV     BAD_SEC,0           ;CLEAR THE BAD SEC COUNT
  183.      MOV     ERR_CNT,0           ;CLEAR THE ERROR COUNT
  184.      MOV     NUM_SEC,1           ;NUMBER OF SECTORS
  185.      CALL     UPD_CYL           ;DISPLAY CYLINDER NUMBER
  186.      CALL     UPD_ERR           ;DISPLAY ERROR COUNT
  187.      WRITE     XS2               ;STATUS
  188.      CLS     LO,4,2,16,78           ;CLEAR THE SCREEN
  189.      CALL     HIDE_CUR           ;HIDE THE CURSOR
  190. ; *********************************************************************
  191. ; *               BEGIN THE TEST                  *
  192. ; *********************************************************************
  193.      MOV     FUNC,ECC_F           ;ECC FUNCTION
  194.      CALL     CTLR_DIAG           ;EXECUTE CTLR HDNOSTICS
  195.      JNC     ECC_30            ;SUCESSFULL
  196.      PMSG     36,HI               ;FAILED
  197.      MOV     ECC_X,36           ;SET CODE
  198.      CALL     UPD_ERR           ;DISPLAY ERROR COUNT
  199.      CMP     ALL_SW,0FFH           ;RUN ALL TEST??
  200.      JE     ECC_28            ;YES
  201.      JMP     ECC_00            ;TERMINATE THE TEST
  202. ECC_28:
  203.      JMP     EXIT               ;EXIT
  204. ECC_30:
  205.      PUSH     DS               ;ESTABLISG
  206.      POP     ES               ;  SEGMENT
  207.      MOV     AX,MAX_CYL           ;POINT TO
  208.      MOV     CUR_CYL,AX           ;  HD CYLINDER
  209.      LEA     BX,DATA_BUF           ;BUFFER
  210.      PUSH     DS               ;ESTABLISH
  211.      POP     ES               ;  SEGMENT
  212. ECC_40:
  213.      MOV     AH,0BH            ;CHECK FOR
  214.      INT     21H               ;  CONTROL BREAK
  215.      CALL     UPD_CYL           ;DISPLAY CURRENT CYLINDER
  216.      MOV     HD_CMD,WR_CMD           ;WRITE COMMAND
  217.      MOV     NUM_SEC,1           ;NUMBER OF SECTORS
  218.      CALL     EXEC_CMD           ;WRITE THE SECTOR
  219.      JNC     ECC_50            ;SUCESSFULL
  220.      CMP     AL,0FFH           ;CTLR BROKE??
  221.      JNE     ECC_48            ;NO
  222.      JMP     ECC_99            ;YES
  223. ECC_48:
  224.      CALL     UPD_ERR           ;DISPLAY ERROR COUNT
  225.      CALL     NEXT_SEC           ;TRY ALL SECTORS
  226.      JNC     ECC_40            ;NEXT
  227.      JMP     ECC_100           ;FAILED
  228. ECC_50:
  229.      MOV     HD_CMD,RD_CMD           ;READ COMMAND
  230.      MOV     NUM_SEC,1           ;NUMBER OF SECTORS
  231.      CALL     EXEC_CMD           ;READ THE SECTOR
  232.      JNC     ECC_60            ;SUCESSFULL
  233.      CMP     AL,0FFH           ;CTLR BROKE??
  234.      JNE     ECC_58            ;NO
  235.      JMP     ECC_99            ;YES
  236. ECC_58:
  237.      JMP     ECC_100           ;FAILED
  238. ECC_60:
  239.      MOV     HD_CMD,RDL_CMD        ;READ LONG COMMAND
  240.      MOV     NUM_SEC,1           ;NUMBER OF SECTORS
  241.      CALL     EXEC_CMD           ;READ THE SECTOR
  242.      JNC     ECC_70            ;SUCESSFULL
  243.      CMP     AL,0FFH           ;CTLR BROKE??
  244.      JNE     ECC_68            ;NO
  245.      JMP     ECC_99            ;YES
  246. ECC_68:
  247.      JMP     ECC_100           ;FAILED
  248. ECC_70:
  249.      MOV     DATA_BUF,0FH           ;FOUR BITS OF CORRECTION
  250.      MOV     HD_CMD,WRL_CMD        ;WRITE LONG COMMAND
  251.      MOV     NUM_SEC,1           ;NUMBER OF SECTORS
  252.      CALL     EXEC_CMD           ;WRITE THE SECTOR
  253.      JNC     ECC_80            ;SUCESSFULL
  254.      CMP     AL,0FFH           ;CTLR BROKE??
  255.      JNE     ECC_78            ;NO
  256.      JMP     ECC_99            ;YES
  257. ECC_78:
  258.      JMP     ECC_100           ;FAILED
  259. ECC_80:
  260.      MOV     HD_CMD,RD_CMD           ;READ COMMAND
  261.      MOV     NUM_SEC,1           ;NUMBER OF SECTORS
  262.      CALL     EXEC_CMD           ;READ THE SECTOR
  263.      JNC     ECC_90            ;SUCESSFULL
  264.      CMP     AL,0FFH           ;CTLR BROKE??
  265.      JNE     ECC_90            ;NO
  266.      JMP     ECC_99            ;YES
  267. ECC_90:
  268.      CMP     AL,11H            ;CORRECTED DATA??
  269.      JE     ECC_93            ;YES
  270.      PUSH     DS               ;SAVE DS
  271.      PUSH     AX               ;SAVE AX
  272.      MOV     AX,40H            ;ESTABLISH
  273.      MOV     DS,AX               ;  SEGMENT
  274.      CMP     BYTE PTR DS:74H,11H   ;ECC CORRECTED??
  275.      POP     AX               ;RESTORE AX
  276.      POP     DS               ;RESTORE DS
  277.      JNE     ECC_100           ;NO - FAILED
  278. ECC_93:
  279.      MOV     HD_CMD,WR_CMD           ;WRITE COMMAND
  280.      MOV     NUM_SEC,1           ;NUMBER OF SECTORS
  281.      CALL     EXEC_CMD           ;GET RID OF THE CORRECTABLE
  282.      MOV     HD_CMD,SEEK_CMD       ;SEEK COMMAND
  283.      MOV     CUR_CYL,0           ; BRING
  284.      MOV     CUR_HD,0           ;  THE HEADS
  285.      CALL     EXEC_CMD           ;  HOME
  286. ECC_95:
  287.      PMSG     35,HI               ;DONE
  288.      MOV     ECC_X,35           ;SET CODE
  289. ECC_99:
  290.      CMP     ALL_SW,0FFH           ;RUN ALL TEST??
  291.      JE     EXIT               ;YES
  292.      LEA     BX,XI4            ;Y/N ENTRY
  293.      CMP     [BX].S_DATA,'Y'       ;RUN FOREVER??
  294.      JE     ECC_110           ;YES
  295.      JMP     ECC_00            ;NEXT
  296. ECC_100:
  297.      PMSG     36,HI               ;FAILED
  298.      MOV     ECC_X,36           ;SET CODE
  299.      CMP     ALL_SW,0FFH           ;RUN ALL TEST??
  300.      JE     EXIT               ;YES
  301.      LEA     BX,XI4            ;Y/N ENTRY
  302.      CMP     [BX].S_DATA,'Y'       ;RUN FOREVER??
  303.      JE     ECC_110           ;YES
  304.      JMP     ECC_00            ;NEXT
  305. ECC_110:
  306.      JMP     ECC_30            ;CONTINUE
  307. ; *********************************************************************
  308. ; *                E X I T                   *
  309. ; *********************************************************************
  310. EXIT:
  311.      RET                   ;RETURN
  312. ECC     ENDP
  313. ; *********************************************************************
  314. ; *            DISPLAY CURRENT CYLINDER              *
  315. ; *********************************************************************
  316. UPD_CYL  PROC
  317.      PUSHALL
  318.      MOV     AX,CUR_CYL           ;FORMAT
  319.      LEA     BX,XC1            ; CYLINDER
  320.      CALL     CONV_ASCII           ;  DISPLAY
  321.      WRITE     XC0               ;CYLINDER
  322.      POPALL
  323.      RET                   ;RETURN
  324. UPD_CYL  ENDP
  325. ; *********************************************************************
  326. ; *               DISPLAY ERROR COUNT                  *
  327. ; *********************************************************************
  328. UPD_ERR  PROC
  329.      PUSHALL
  330.      XOR     AX,AX               ;CLEAR AX
  331.      MOV     AX,ERR_CNT           ;FORMAT
  332.      LEA     BX,XE1            ; ERROR COUNT
  333.      CALL     CONV_ASCII           ;  DISPLAY
  334.      WRITE     XE0               ;ERROR COUNT
  335.      POPALL
  336.      RET                   ;RETURN
  337. UPD_ERR  ENDP
  338. CSEG     ENDS
  339.      END     HDECC
  340.